#include "logindialog.h"
#include "ui_logindialog.h"
#include<QDebug>
#include<QIcon>
logindialog::logindialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::logindialog),
    reg(new RegisterDialog),
    mw(new gobang)
{
    ui->setupUi(this);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
    //ui->label->setPixmap(QPixmap("../my_gobang/picture/myjpg.jpg"));
    //ui->label->setScaledContents(true);
}

logindialog::~logindialog()
{
    delete ui;
    //delete reg;
    delete mw;
}

void logindialog::on_pushButton_clicked()
{
    reg->show();//注册
}

void logindialog::on_pushButton_2_clicked()//登录
{
    bool flag=false;
    QString username=ui->lineEdit->text();
    QString password=ui->lineEdit_2->text();
    query.exec("select * from users");
    while(query.next())
    {
        if((query.value(0).toString()==username)&&(query.value(1).toString()==password))//登陆成功
        {
            mw->show();
            this->hide();
            flag=true;
            break;
        }
    }
    if(!flag)//登陆失败
    {
        QString mytitle="提示框";
        QString myinfo="用户名或密码错误！";
        QMessageBox::warning(this,mytitle,myinfo);
        ui->lineEdit->clear();
        ui->lineEdit_2->clear();
    }

}
